<template>
  <div class="wrapper example1-container">
    <!-- 返回区域 -->
    <div
      class="back-box"
      @click="$router.go(-1)"
    >返回</div>

    <!-- 标题区域 -->
    <h1 class="title-box">1、初始setup</h1>

    <!-- 实例区域 -->
    <div class="example1-box">
      <h1>一个人的信息</h1>
      <h2>姓名：{{ name }}</h2>
      <h2>年龄：{{ age }}</h2>
      <button @click="sayHello">说话</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Example1',
  setup() {
    // 数据
    const name = '张三';
    const age = 20;

    // 方法
    const sayHello = () => {
      alert(`我叫${name}，我今年${age}岁了`);
    };

    return {
      name,
      age,
      sayHello
    };
  }
};
</script>

<style lang="scss" scoped>
.example1-container {
  // 返回区域
  & > .back-box {
    width: 50px;
    height: 23px;
    line-height: 20px;
    text-align: center;
    background-color: #efefef;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid #767676;
    border-radius: 4px;
    cursor: pointer;
  }

  // 标题区域
  & > .title-box {
    margin-bottom: 30px;
  }

  // 实例区域
  & > .example1-box {
    & > h1 {
      margin-bottom: 20px;
    }
    & > h2 {
      margin-bottom: 20px;
    }
    & > button {
      cursor: pointer;
    }
  }
}
</style>
